<template>
	<view>
		<cu-custom bgColor="bg-gradual-pink">
			<block slot="content">客户首页</block>
		</cu-custom>
		<view class="title">
			<image src="/static/24.png" mode=""></image>
		</view>
		<view class="swiper">
			<swiper style="height: 380upx;background-color: #FFFFFF;" circular autoplay duration="1000">
				<swiper-item v-for="(item,index) in image" :key='index'>
						<view style="padding: 0upx 30upx 20upx 30upx;height: 100%;">
							<image style="width: 100%;height: 100%;" :src="item.src" @click="jump" :data-src='item.path'></image>
						</view>
				</swiper-item>
			 </swiper>
		</view>
		<view style="margin-top: 15upx;width: 100%;background-color: #fff;">
			<view style="line-height: 80upx;font-size: 38upx;margin-left: 30upx;">
				常用功能
			</view>
			<view style="display: flex;padding: 0 30upx;">
				<view style="margin: 0upx 20upx 30upx 20upx;" v-for="(item,index) in menus" :key='index'>
					<view @click="jump" :data-src='item.path'>
						<image style="width: 100upx;height: 100upx;border-radius: 15upx;" :src="item.src" mode=""></image>
					</view>
					<view style="font-size: 20upx;color: #666;text-align: center;">
						{{item.title}}
					</view>
				</view>
			</view>
		</view>
		<view style="margin-top: 15upx;width: 100%;background-color: #fff;">
			<view style="display: flex;justify-content: space-between;">
				<view style="line-height: 80upx;font-size: 38upx;margin-left: 30upx;">
					客户列表
				</view>
				<view style="line-height: 80upx;font-size: 38upx;margin-right: 30upx;" @click="jump" data-src='/pagesA/maillist/maillist'>
					<text style="font-size: 30upx;color: #3A89BE;font-weight: 500;">查看全部</text>
					<text class="cuIcon-right margin-top-sm"></text>
				</view>
			</view>
			<view style="display: flex;padding-left: 30upx;">
				<view style="margin: 0upx 20upx 30upx 20upx;" @click="jump" data-src='/pagesA/add_customer/add_customer'>
					<view>
						<image style="width: 90upx;height: 90upx;border-radius: 50upx;" src="/static/tianjia.png" mode=""></image>
					</view>
					<view style="font-size: 22upx;color: #666;text-align: center;color: #3A89BE;">
						添加客户
					</view>
				</view>
				<view style="width: 7upx;height: 100upx;background-color: #F8F8F8;"></view>
				<scroll-view scroll-x="true" style="width: 575upx;">
					<view style="display: flex;">
						<view style="margin: 0 20upx;" v-for="(item,index) in records" :key='index'>
							<view @click="jump" :data-src='"/pagesA/customer_details/customer_details?id="+item.id'>
								<image style="width: 90upx;height: 90upx;border-radius: 50upx;" :src="item.avatar" mode=""></image>
							</view>
							<view style="font-size: 20upx;color: #666;text-align: center;">
								{{item.name.substr(0, 4)}}
							</view>
						</view>
					</view>
				</scroll-view>
			</view>
		</view>
		<view style="margin-top: 10upx;background-color: #fff;padding: 30upx;">
			<view style="display: flex;justify-content: space-between;">
				<view style="background-color: #F1F5FC;border-radius: 15upx;width: 340upx;height: 210upx;padding: 30upx;">
					<view style="line-height: 50upx;">
						私教客户
					</view>
					<view style="display: flex;justify-content: space-between;">
						<view>
							<view style="font-size: 65upx;">
								0
							</view>
							<view style="font-size: 22upx;">
								最近未上课
							</view>
						</view>
						<view>
							<view style="font-size: 65upx;">
								0
							</view>
							<view style="font-size: 22upx;">
								剩余课时少
							</view>
						</view>
					</view>
				</view>
				<view style="background-color: #FCF4F1;border-radius: 15upx;width: 340upx;height: 210upx;padding: 30upx;margin-bottom: 200upx;">
					<view style="line-height: 50upx;">
						潜在客户
					</view>
					<view style="display: flex;justify-content: space-between;">
						<view>
							<view style="font-size: 65upx;">
								0
							</view>
							<view style="font-size: 22upx;">
								近期录入
							</view>
						</view>
						<view>
							<view style="font-size: 65upx;">
								0
							</view>
							<view style="font-size: 22upx;">
								近期体测
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				image : [
					{
						src : 'cloud://jianshen-6g5fzx5gfbc2096b.6a69-jianshen-6g5fzx5gfbc2096b-1304015367/333_03.png',
						path : 'Not-yet-open'
					},
					{
						src : 'cloud://jianshen-6g5fzx5gfbc2096b.6a69-jianshen-6g5fzx5gfbc2096b-1304015367/2222_03.png',
						path : 'Not-yet-open'
					},
					
				],
				menus : [
					{
						title : '关于我们',
						src : '/static/about_us.png',
						path : '/pagesA/about_us/about_us'
					},
					{
						title : '其他页面',
						src : '/static/componentBg.png',
						path : 'Not-yet-open'
					},
					{
						title : '其他页面',
						src : '/static/BasicsBg.png',
						path : 'Not-yet-open'
					},
					{
						title : '其他页面',
						src : '/static/componentBg.png',
						path : 'Not-yet-open'
					},
					{
						title : '其他页面',
						src : '/static/BasicsBg.png',
						path : 'Not-yet-open'
					},
				],
				records : [],
			}
		},
		onReady() {
			let that = this;
			uni.getStorage({
				key: 'openid',
				success: (res) => {
					that.openid = res.data
					that.setajax()
			 },
			 fail: () => {
			 }
			});
		},
		methods: {
			setajax(){
				var data = {
					'openid': this.openid,
				}
				console.log(data)
				uni.request({
					url: 'https://wechatdemo.mygodmall.com/app/index.php?i=4&c=entry&m=ewei_shopv2&do=mobile&r=member.biaodan_list&app=1',
					method: 'POST',
					data: data,
					header:{'Content-Type':'application/x-www-form-urlencoded'},
					success: res => {
						console.log(res)
						this.records = res.data.list
					},
					fail: () => {},
					complete: () => {}
				});
			},
			jump(e){
				console.log(e.currentTarget.dataset.src)
				if ( e.currentTarget.dataset.src == 'Not-yet-open') {
					uni.showModal({
						title:'提示',
						content:'功能即将开放',
						showCancel: false,
						confirmColor:"#DD524D",
							success() {
								return
							}
					})
				} else {
					uni.navigateTo({
						url: e.currentTarget.dataset.src
					});
				}
			},
		}
	}
</script>

<style lang="scss">
	.headerBar {
		width: 100%;
		height: 130upx;
		background-color: #525969;
		position: fixed;
		top: 0;
		z-index: 999;
		.headerBar_title {
			color: #fff;
			line-height: 130upx;
			font-size: 38upx;
			margin-left: 40upx;
		}
	}
		.title {
			background-color: #fff;
			// margin-top: 130upx;
			width: 100%;
			text-align: center;
			image {
				width: 250upx;
				height: 130upx;
			}
		}
			
</style>
